/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.mto.quangcao.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.mto.quangcao.service.position_bannerLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author thanh.tran
 */
public class position_bannerClp extends BaseModelImpl<position_banner>
	implements position_banner {
	public position_bannerClp() {
	}

	public Class<?> getModelClass() {
		return position_banner.class;
	}

	public String getModelClassName() {
		return position_banner.class.getName();
	}

	public long getPrimaryKey() {
		return _positionId;
	}

	public void setPrimaryKey(long primaryKey) {
		setPositionId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_positionId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("positionId", getPositionId());
		attributes.put("positionName", getPositionName());
		attributes.put("groupCategoryId", getGroupCategoryId());
		attributes.put("pageCategoryId", getPageCategoryId());
		attributes.put("width", getWidth());
		attributes.put("height", getHeight());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long positionId = (Long)attributes.get("positionId");

		if (positionId != null) {
			setPositionId(positionId);
		}

		String positionName = (String)attributes.get("positionName");

		if (positionName != null) {
			setPositionName(positionName);
		}

		Long groupCategoryId = (Long)attributes.get("groupCategoryId");

		if (groupCategoryId != null) {
			setGroupCategoryId(groupCategoryId);
		}

		Long pageCategoryId = (Long)attributes.get("pageCategoryId");

		if (pageCategoryId != null) {
			setPageCategoryId(pageCategoryId);
		}

		Long width = (Long)attributes.get("width");

		if (width != null) {
			setWidth(width);
		}

		Long height = (Long)attributes.get("height");

		if (height != null) {
			setHeight(height);
		}
	}

	public long getPositionId() {
		return _positionId;
	}

	public void setPositionId(long positionId) {
		_positionId = positionId;
	}

	public String getPositionName() {
		return _positionName;
	}

	public void setPositionName(String positionName) {
		_positionName = positionName;
	}

	public long getGroupCategoryId() {
		return _groupCategoryId;
	}

	public void setGroupCategoryId(long groupCategoryId) {
		_groupCategoryId = groupCategoryId;
	}

	public long getPageCategoryId() {
		return _pageCategoryId;
	}

	public void setPageCategoryId(long pageCategoryId) {
		_pageCategoryId = pageCategoryId;
	}

	public long getWidth() {
		return _width;
	}

	public void setWidth(long width) {
		_width = width;
	}

	public long getHeight() {
		return _height;
	}

	public void setHeight(long height) {
		_height = height;
	}

	public BaseModel<?> getposition_bannerRemoteModel() {
		return _position_bannerRemoteModel;
	}

	public void setposition_bannerRemoteModel(
		BaseModel<?> position_bannerRemoteModel) {
		_position_bannerRemoteModel = position_bannerRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			position_bannerLocalServiceUtil.addposition_banner(this);
		}
		else {
			position_bannerLocalServiceUtil.updateposition_banner(this);
		}
	}

	@Override
	public position_banner toEscapedModel() {
		return (position_banner)Proxy.newProxyInstance(position_banner.class.getClassLoader(),
			new Class[] { position_banner.class },
			new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		position_bannerClp clone = new position_bannerClp();

		clone.setPositionId(getPositionId());
		clone.setPositionName(getPositionName());
		clone.setGroupCategoryId(getGroupCategoryId());
		clone.setPageCategoryId(getPageCategoryId());
		clone.setWidth(getWidth());
		clone.setHeight(getHeight());

		return clone;
	}

	public int compareTo(position_banner position_banner) {
		long primaryKey = position_banner.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		position_bannerClp position_banner = null;

		try {
			position_banner = (position_bannerClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = position_banner.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{positionId=");
		sb.append(getPositionId());
		sb.append(", positionName=");
		sb.append(getPositionName());
		sb.append(", groupCategoryId=");
		sb.append(getGroupCategoryId());
		sb.append(", pageCategoryId=");
		sb.append(getPageCategoryId());
		sb.append(", width=");
		sb.append(getWidth());
		sb.append(", height=");
		sb.append(getHeight());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.mto.quangcao.model.position_banner");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>positionId</column-name><column-value><![CDATA[");
		sb.append(getPositionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>positionName</column-name><column-value><![CDATA[");
		sb.append(getPositionName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupCategoryId</column-name><column-value><![CDATA[");
		sb.append(getGroupCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>pageCategoryId</column-name><column-value><![CDATA[");
		sb.append(getPageCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>width</column-name><column-value><![CDATA[");
		sb.append(getWidth());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>height</column-name><column-value><![CDATA[");
		sb.append(getHeight());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _positionId;
	private String _positionName;
	private long _groupCategoryId;
	private long _pageCategoryId;
	private long _width;
	private long _height;
	private BaseModel<?> _position_bannerRemoteModel;
}